<template>
  <div class="mod-user">
    <el-dialog
      v-el-drag-dialog
      title="提现详情"
      :visible.sync="visible"
      width="60%">
      <el-row :gutter="20">
        <el-col :span="9">
          <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
              <el-input v-model="dataForm.keywords" placeholder="提现账户" clearable style="width: 100px;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-form-item>
                <el-select v-model="dataForm.userType" placeholder="用户类型" :value="dataForm.userType"  style="width: 110px;">
                  <el-option
                    v-for="type in typeNameList"
                    :key="type.val"
                    :label="type.label"
                    :value="type.val">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataList()">查询</el-button>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="15" class="money-tag">
          <el-tag type="success">推广可提现余额:{{extensionMoney.commissionMoney}}</el-tag>
          <el-tag type="success">账户未提现余额:{{extensionMoney.notExtract}}</el-tag>
          <el-tag type="success">账户已提现余额:{{extensionMoney.yesExtract}}</el-tag>
          <el-tag type="danger">商家收益总额:{{extensionMoney.profit}}</el-tag>
        </el-col>
      </el-row>
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        @selection-change="selectionChangeHandle"
        style="width: 100%;">
        <el-table-column
          prop="paUserName"
          header-align="center"
          align="center"
          label="支付账号">
        </el-table-column>
        <el-table-column
          prop="paUserTrueName"
          header-align="center"
          align="center"
          label="用户名称">
        </el-table-column>
        <el-table-column
          prop="paUserType"
          header-align="center"
          align="center"
          label="用户类型">
          <template slot-scope="scope">
            <el-tag type="primary"
                    disable-transitions>{{memberType[scope.row.paUserType]}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="totalMoney"
          header-align="center"
          align="center"
          label="收益金额">
        </el-table-column>
        <el-table-column
         prop="arriveMoney"
         header-align="center"
         align="center"
         label="实际到账">
        </el-table-column>
        <el-table-column
          prop="storeTrueName"
          header-align="center"
          align="center"
          width="150"
          label="商家名称">
        </el-table-column>
        <el-table-column
          prop="storeUserName"
          header-align="center"
          align="center"
          label="商家手机号">
        </el-table-column>
        <el-table-column
          prop="storeUserType"
          header-align="center"
          align="center"
          label="商家类型">
          <template slot-scope="scope">
            <el-tag type="primary"
                    disable-transitions>{{memberType[scope.row.storeUserType]}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="createTime"
          header-align="center"
          align="center"
          label="订单创建时间">
        </el-table-column>
        <el-table-column
        prop="orderType"
        header-align="center"
        align="center"
        label="订单类型">
          <template slot-scope="scope">
            <el-tag type="primary" disable-transitions v-if="scope.row.orderType === 1">线下订单</el-tag>
            <el-tag type="primary" disable-transitions v-else-if="scope.row.orderType === 2">推广收益</el-tag>
            <el-tag type="primary" disable-transitions v-else-if="scope.row.orderType === 3">线上订单</el-tag>
          </template>
      </el-table-column>
      </el-table>

      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </el-dialog>
  </div>
</template>

<script>
  import {typeNameList, typeName} from '@/utils/memberType'
  export default {
    data () {
      return {
        dataForm: {
          userType: '',
          keywords: ''
        },
        id: 0,
        typeNameList: typeNameList,
        extensionMoney: [],
        memberType: typeName,
        visible: false,
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        extractMoneyDetailsVisible: false
      }
    },
    components: {
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList (id) {
        this.visible = true
        if (this.id === 0) {
          this.id = id
        }
        if (id === undefined) {
          id = this.id
        } else {
          this.dataForm.time = new Date()
          console.log(this.dataForm.time)
        }
        this.$http({
          url: this.$http.adornUrl('/member/user/queryMerchantIncomeList'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex - 1,
            'limit': this.pageSize,
            'withUserId': id,
            'getUserType': this.dataForm.userType,
            'keywords': this.dataForm.keywords
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.data.data.list
            this.totalPage = data.data.data.totalCount
            this.extensionMoney = data.data.extensionMoney
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      a (rowIndex) {
        alert(rowIndex)
      }
    }
  }
</script>
<style>
  .characters{
    width:300px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .el-dialog__body {
    height: 500px;
    overflow-y: scroll;
  }
  .money-tag .el-tag--medium {
    height: 32px;
    line-height: 33px;
  }
</style>
